import scopt.test.common
from scopt.mpu.context.tenant.handlers import create, param_get


class TenantCreateTest(scopt.test.common.ScoptTest):
    '''Tenant Create tests
    MPU should:

    1. test_tenant_create_naked
        create tenant withour parameters
    2. test_tenant_create_with_parameters
    '''
    def setUp(self):
        super(TenantCreateTest, self).setUp()
        self.__company_name = 'My Company'

    def test_tenant_create_naked(self):
        request = self.request(create.handle)
        request['reqd']['tenant_name'] = self.__company_name

        response = self.send_request(request)
        resd = response['resd']
        tenant_id = resd['tenant_id']

        self.assertGreater(len(tenant_id), 0)
        self.assertEqual(resd['tenant_name'], self.__company_name)

    def test_tenant_create_with_parameters(self):
        request = self.request(create.handle)
        request['reqd']['tenant_name'] = self.__company_name
        request['reqd']['params'] = {'param1': 'value1',
                                     'param2': 'value2'}

        response = self.send_request(request)
        resd = response['resd']
        tenant_id = resd['tenant_id']

        self.assertGreater(len(tenant_id), 0)
        self.assertEqual(resd['tenant_name'], self.__company_name)

        request = self.request(param_get.handle)
        request['reqd']['tenant_id'] = tenant_id
        request['reqd']['param_names'] = ('param1', 'param2')

        response = self.send_request(request)
        resd = response['resd']
